﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class View_Admin_QuanLyHoaDonNhap : System.Web.UI.Page
{
    QLHoaDonNhap hdn = new QLHoaDonNhap();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            GridView1.DataSource = hdn.Load_HDNhap();
            GridView1.DataBind();

            dropMaNCC.DataSource = hdn.Load_DropNCC();
            dropMaNCC.DataValueField = "mancc";
            dropMaNCC.DataTextField = "tenncc";
            dropMaNCC.DataBind();

            dropMaHoa.DataSource = hdn.Load_DropHoa();
            dropMaHoa.DataValueField = "mahoa";
            dropMaHoa.DataTextField = "tenhoa";
            dropMaHoa.DataBind();
        }
    }
    protected void btnThem_Click(object sender, EventArgs e)
    {
        string ngaynhap=DateTime.Now.Date.ToString();
        string mahdn = hdn.Insert_HDNhap(dropMaNCC.SelectedValue, ngaynhap);
        hdn.Insert_CTHDNhap(mahdn, dropMaHoa.SelectedValue, int.Parse(txtSL.Text), float.Parse(txtDGia.Text));
        GridView1.DataSource = hdn.Load_HDNhap();
        GridView1.DataBind();
        txtDGia.Text = "";
        txtSL.Text = "";
        lblThongBao.Text = "Đã thêm thành công!!!";
    }
}
